package com.boge.ai.controller;

import com.boge.ai.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.Map;

@RestController
public class Chat2Controller {

    @Autowired
    private ChatClient client;


    @GetMapping("/ai2/generate")
    public Map generate(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {

        return Map.of("generation", this.client.prompt(message).call().content());
    }

    @GetMapping("/ai2/generateStream")
    public Map generateStream(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {

        return Map.of("generation", this.client.prompt(message).stream().content());
    }


}
